<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class baseController extends MY_Controller{
	public function __construct(){
		parent::__construct();	
        $this->load->library('session');
        $this->load->helper('text');
        
        $this->_data['servicesParent'] = $this->getServicesParent();
        $this->_data['servicesSub'] = $this->getServicesSub();
        $this->_data['nearlyProjects'] = $this->getNearlyProject(2);
        $this->_data['featuredProjects'] = $this->getNearlyProject(5);
        $this->_data['nearlyFaqs'] = $this->getNearlyFaqs(5);
        $this->_data['nearlyEntries'] = $this->getNearlyEntries(2);
        $this->_data['banners'] = $this->getBanners();
        $this->_data['socials'] = $this->getSocial();
        $this->_data['about'] = $this->getAbout(1);
        $this->_data['about1'] = $this->getAbout(2);
        $this->_data['about2'] = $this->getAbout(3);
        $this->_data['about3'] = $this->getAbout(4);
	}
	
    public function getServicesParent() {
        $services = $this->servicesModel->get_by(array('parentId' => 0, 'languageCode' => $this->session->userdata('languageCode')), array('number' => 'asc'));
        return $services;
    }
    
    public function getServicesSub() {
        $services = $this->servicesModel->get_by(array('parentId > ' => 0, 'languageCode' => $this->session->userdata('languageCode')), array('number' => 'asc'));
        return $services;
    }
    
    public function getNearlyProject($limit=null) {
        return $this->projectModel->get_by(array('languageCode' => $this->session->userdata('languageCode')), array('id' => 'desc'), $limit);
    }
    
    public function getNearlyFaqs($limit=null) {
        return $this->faqModel->get_by(array('languageCode' => $this->session->userdata('languageCode')), array('id' => 'desc'), $limit);
    }
    
    public function getNearlyEntries($limit=null) {
        return $this->entryModel->get_by(array('languageCode' => $this->session->userdata('languageCode')), array('id' => 'desc'), $limit);
    }
    
    public function getBanners($limit=null) {
        return $this->bannerModel->get_by(array('languageCode' => $this->session->userdata('languageCode')), array('number' => 'asc'), $limit);
    }
    
    public function getAbout($id) {
        return $this->infoModel->read(array('languageCode' => $this->session->userdata('languageCode'), 'infoId' => $id));
    }
    
    public function getSocial($id=1) {
        return $this->socialModel->read($id);
    }
    
	public function loadView($data = null){
		$this->load->view('templates',$data);
	}
    
	public function loadStatic($template,$data = null){
		return $this->load->view($template,$data,TRUE);
	}
}
